import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/model/service_order/service_order_model.dart';
import 'package:ls_work/net/response/employee_list_data.dart';

class MultiChooseEmployeeViewModel extends BaseListViewModel<EmployeeListData>{
  MultiChooseEmployeeViewModel(BuildContext context) : super(context);

  var model = ServiceOrderModel();
  var customer = '';
  @override
  Future<List<EmployeeListData>> requestListData() async {
    return await model.wholeEmployeeList(0, customer, page, pageLength);
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

  var selectItems = <EmployeeListData>[];

  void itemTap(int index){
    var item = listItems[index];
    if(selectItems.contains(item)){
      selectItems.remove(item);
    }else{
      selectItems.add(item);
    }
    notifyListeners();
  }

  void allChoose(bool choose){
    if(choose){
      selectItems.clear();
      selectItems.addAll(listItems);
    }else{
      selectItems.clear();
    }
    notifyListeners();
  }
}